
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="page/head.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <form method="post" action="/emp?method=updateEmp">
                <div class="form-group">
                    <label for="exampleInputEmail1">员工名</label>
                    <input type="hidden" name="eno" value="${e.eno}">
                    <input type="text" class="form-control" name="ename" id="exampleInputEmail1" value="${e.ename}"
                           placeholder="ename">
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">密码</label>
                    <input type="password" class="form-control" value="${e.pwd}" name="pwd" id="exampleInputPassword1"
                           placeholder="Password">
                </div>
                <div class="form-group">
                    <label>性别</label>
                    <label class="radio-inline">

                        <input type="radio" name="esex" id="inlineRadio1" value="男" ${e.esex=='男'?"checked":""}> 男
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="esex" id="inlineRadio2" value="女" ${e.esex=='女'?"checked":""}> 女
                    </label>
                </div>
                <div class="form-group">
                    <label for="salary">工资</label>
                    <input type="number" class="form-control" name="salary" value="${e.salary}" id="salary"
                           placeholder="salary">
                </div>
                <div class="form-group">
                    <label for="salary">部门</label>
                    <input type="hidden" id="userDno" value="${e.dno}">
                    <select class="form-control" name="dno" id="dno">
                    </select>
                </div>
                <div class="form-group">
                    <label for="bornDate">出生日期</label>
                    <input type="date" class="form-control" name="born_date"
                           value="<fm:formatDate value='${e.bornDate}' pattern='yyyy-MM-dd'/>" id="bornDate">
                </div>
                <button type="submit" class="btn btn-default">新增</button>
            </form>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: "/dept?method=getAll",
            type: "get",
            dataType: "json",
            success: function (result) {
                var d = $("#userDno").val();
                for (let x in result) {
                    if (d==result[x].dno) {
                        $("#dno").append("<option selected value='" + result[x].dno + "'>" + result[x].dname + "</option>");
                    }else{
                        $("#dno").append("<option value='" + result[x].dno + "'>" + result[x].dname + "</option>");
                    }

                }
            }
        })
    })
</script>
</body>
</html>
